﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace iNet.Media.Xmp
{
	public class FlashXmpPropertyValue : StructureXmpPropertyValue
	{
		#region 建構子
		public FlashXmpPropertyValue()
			: this(CommonXmpSchemas.ExifSpecific)
		{ }
		public FlashXmpPropertyValue(XmpSchema schema)
			: base(schema)
		{
			if (schema == null)
				throw new ArgumentNullException("schema");
			this.Fired = new BooleanXmpPropertyValue(false);
			this.Function = new BooleanXmpPropertyValue(true);
			this.Mode = new IntegerXmpPropertyValue(0);
			this.RedEyeMode = new BooleanXmpPropertyValue(false);
			this.Return = new IntegerXmpPropertyValue(0);
		}
		#endregion
		#region CloneCore
		protected override XmpPropertyValue CloneCore()
		{
			FlashXmpPropertyValue value = new FlashXmpPropertyValue(this.Schema);
			this.CopyFieldsTo(value);
			return value;
		}
		#endregion
		#region FieldNames
		public override string[] FieldNames
		{
			get 
			{
				return new string[]{
					"Fired",
					"Function",
					"Mode",
					"RedEyeMode",
					"Return",
				};
			}
		}
		#endregion
		#region Fired
		public BooleanXmpPropertyValue Fired { get; set; }
		#endregion
		#region Function
		public BooleanXmpPropertyValue Function { get; set; }
		#endregion
		#region GetFieldCore
		protected override XmpPropertyValue GetFieldCore(string name)
		{
			switch (name)
			{
				case "Fired":
					return this.Fired;
				case "Function":
					return this.Function;
				case "Mode":
					return this.Mode;
				case "RedEyeMode":
					return this.RedEyeMode;
				case "Return":
					return this.Return;
				default:
					throw new ArgumentException();
			}
		}
		#endregion
		#region Mode
		public IntegerXmpPropertyValue Mode { get; set; }
		#endregion
		#region RedEyeMode
		public BooleanXmpPropertyValue RedEyeMode { get; set; }
		#endregion
		#region Return
		public IntegerXmpPropertyValue Return { get; set; }
		#endregion
		#region SetFieldCore
		protected override void SetFieldCore(string name, XmpPropertyValue value)
		{
			switch (name)
			{
				case "Fired":
					if (value == null || value is BooleanXmpPropertyValue)
						this.Fired = (value as BooleanXmpPropertyValue);
					else
						throw new ArgumentException();
					break;
				case "Function":
					if (value == null || value is BooleanXmpPropertyValue)
						this.Function = (value as BooleanXmpPropertyValue);
					else
						throw new ArgumentException();
					break;
				case "Mode":
					if (value == null || value is IntegerXmpPropertyValue)
						this.Mode = (value as IntegerXmpPropertyValue);
					else
						throw new ArgumentException();
					break;
				case "RedEyeMode":
					if (value == null || value is BooleanXmpPropertyValue)
						this.RedEyeMode = (value as BooleanXmpPropertyValue);
					else
						throw new ArgumentException();
					break;
				case "Return":
					if (value == null || value is IntegerXmpPropertyValue)
						this.Return = (value as IntegerXmpPropertyValue);
					else
						throw new ArgumentException();
					break;
				default:
					throw new ArgumentException();
			}
		}
		#endregion
	}

	public class FlashXmpPropertyValueFactory : StructureXmpPropertyValueFactory<FlashXmpPropertyValue>
	{
		#region 建構子
		public FlashXmpPropertyValueFactory()
			: base(CommonXmpSchemas.ExifSpecific.NamespaceURI, new string[] { "Fired", "Function", "Mode", "RedEyeMode", "Return" })
		{ }
		#endregion
		#region CreateValue
		protected override FlashXmpPropertyValue CreateValue(XmpSchema schema)
		{
			return new FlashXmpPropertyValue(schema);
		}
		#endregion
	}
}
